<!-- INCLUDE sv_overall_header.html -->


<SCRIPT>
function validate()
{	
	var corp_id = get_selected_corp_id();
	
	if (corp_id == '')
	{
		// it will be empty if there is only one radio. 
		corp_id = 	document.forms['sell_form'].elements['corp_id'].value;
	}

	var number_id = corp_id + "_number";
	
	var	number_to_sell = parseInt(document.forms['sell_form'].elements[number_id].value);
	
	var number_id = corp_id + "_sellable_number";
	var	number_sellable = parseInt(document.forms['sell_form'].elements[number_id].value);

	if (number_to_sell > number_sellable)
	{
		alert("{L_SV_NOT_ENOUGH_SHARE_SELL}");
		return false;
	}

	return true;
}

function get_selected_corp_id()
{
	var	radio_corp_id = document.forms['sell_form'].elements['corp_id'];

	for (i = 0; i < radio_corp_id.length; ++i)
	{
		if (radio_corp_id.item(i).checked == true)
			return radio_corp_id.item(i).value;
	}

	return '';
}

function number_change(number)
{
	var postfix		= "_number";
	var number_id	= number.id;
	var to			= number_id.length - postfix.length;	
	var corp_id		= number_id.substring(0, to);

	var	radio_corp_id = document.forms['sell_form'].elements['corp_id'];

	for (i = 0; i < radio_corp_id.length; ++i)
	{
		if (radio_corp_id.item(i).value == corp_id)
			radio_corp_id.item(i).checked = true;			
	}
}

</SCRIPT>

<!-- IF not S_USER_LOGGED_IN and not S_IS_BOT -->
	<form method="post" action="{S_LOGIN_ACTION}" class="headerspace">
	<h3><a href="{U_LOGIN_LOGOUT}">{L_LOGIN_LOGOUT}</a><!-- IF S_REGISTER_ENABLED -->&nbsp; &bull; &nbsp;<a href="{U_REGISTER}">{L_REGISTER}</a><!-- ENDIF --></h3>
		<fieldset class="quick-login">
			<label for="username">{L_USERNAME}:</label>&nbsp;<input type="text" name="username" id="username" size="10" class="inputbox" title="{L_USERNAME}" />
			<label for="password">{L_PASSWORD}:</label>&nbsp;<input type="password" name="password" id="password" size="10" class="inputbox" title="{L_PASSWORD}" />
			<!-- IF S_AUTOLOGIN_ENABLED -->
				| <label for="autologin">{L_LOG_ME_IN} <input type="checkbox" name="autologin" id="autologin" /></label>
			<!-- ENDIF -->
			<input type="submit" name="login" value="{L_LOGIN}" class="button2" />
			{S_LOGIN_REDIRECT}
		</fieldset>
	</form>
<!-- ENDIF -->


<!-- IF S_HOLDING_STOCK_LIST  -->
<div class="panel" > 
	<div class="inner"><span class="corners-top"><span></span></span> 
	<h2>{L_SV_SELL}</h2> 
	</div>
	<form name="sell_form" method="post" action="{S_SELL_ACTION}" onsubmit="return validate();">
		
	<table border="0" cellpadding="5" cellspacing="5">
		<tr>
			<td><p> </p></td>
			<td><p> </p></td>
			<td><p>{L_SV_STOCK_ID}</p></td>
			<td><p>{L_SV_CORP_NAME}</p></td>
			<td><p>{L_SV_SEELABLE_NUMBER}</p></td>
			<td><p>{L_SV_HOLDING_NUMBER}</p></td>
			<td><p>{L_SV_TO_SELL_NUMBER}</p></td>
			<td><p>{L_SV_COST}</p></td>
			<td><p>{L_SV_REFERED_PRICE}</p></td>				
		</tr>
		<!-- BEGIN holding_stock_list -->
		<tr>
			<!-- IF holding_stock_list.CANNOT_SELL  -->
			<td><p> <input type="radio" name="corp_id" value="{holding_stock_list.CORP_ID}" disabled="disabled"> </p></td>
			<td><p> <input type="text" name="{holding_stock_list.CORP_ID}_number" size="10" value="0" disabled="disabled"> </p></td>
			<!-- ELSE -->
			<td><p> <input type="radio" name="corp_id" value="{holding_stock_list.CORP_ID}" checked> </p></td>
			
			
			<td><p>
				<select name="{holding_stock_list.CORP_ID}_number" id="{holding_stock_list.CORP_ID}_number" class="row2" title="{L_SV_NUMBER}" onchange="number_change(this);">
					<OPTION VALUE="1" SELECTED>1 </OPTION>
					<!-- IF holding_stock_list.SELLABLE_NUMBER >= 2  --> <OPTION VALUE="2"> 2 </OPTION> <!-- ENDIF -->
					<!-- IF holding_stock_list.SELLABLE_NUMBER >= 3  --> <OPTION VALUE="3"> 3 </OPTION> <!-- ENDIF -->
					<!-- IF holding_stock_list.SELLABLE_NUMBER >= 4  --> <OPTION VALUE="4"> 4 </OPTION> <!-- ENDIF -->
					<!-- IF holding_stock_list.SELLABLE_NUMBER >= 5  --> <OPTION VALUE="5"> 5 </OPTION> <!-- ENDIF -->
					<!-- IF holding_stock_list.SELLABLE_NUMBER >= 10  --> <OPTION VALUE="10"> 10 </OPTION> <!-- ENDIF -->
					<!-- IF holding_stock_list.SELLABLE_NUMBER >= 20  --> <OPTION VALUE="20"> 20 </OPTION> <!-- ENDIF -->					
				</select>
			</p></td>
			<!-- ENDIF -->
			<td><p>{holding_stock_list.CORP_ID}</p></td>
			<td><p>{holding_stock_list.CORP_NAME}</p></td>
			<td><p>{holding_stock_list.SELLABLE_NUMBER} 
				<input type="hidden" name="{holding_stock_list.CORP_ID}_sellable_number" size="10" value="{holding_stock_list.SELLABLE_NUMBER}">
			</p></td>
			<td><p>{holding_stock_list.HOLDING_NUMBER}</p></td>
			<td><p>{holding_stock_list.TO_SELLNUMBER}</p></td>
			<td><p>{holding_stock_list.COST}</p></td>
			<td><p>{holding_stock_list.REFERED_PRICE}</p></td>	
			
		</tr>
		<!-- END holding_stock_list -->

		<tr> <td><p> </p></td> </tr>
	</table>
	<table width="40%">
		<tr> 
			<td width="40"><label for="note"><p>{L_SV_NOTE}:</label> </p></td> 
			<td  aligh="left"> <input type="textarea" name="note" id="note" size="200" class="inputbox" title="{L_SV_NOTE}" /></p></td>
		</tr>
		<tr>
			<td><p> <input type="submit" name="login" value="{L_SV_SEND}" class="button2" /></p></td>
		</tr>
	</table>
	
	</form>
</div>
<!-- ELSE -->
<div class="panel" > 
	<div class="inner"><span class="corners-top"><span></span></span> 
	<h2>{L_SV_SELL}</h2> 
	</div>
	<h3>{L_SV_NO_HOLDING_STOCK}</h3>
</div>
<!-- ENDIF -->

<!-- INCLUDE to_sell_delegation_list.html -->

<!-- INCLUDE sv_overall_footer.html -->